(function() {
    'use strict';
    var editTextItem = {};
    vueSticky.install = Vue => {
        Vue.directive('editTextItem', function () {
            var _this = this;
            var target = this.el;

            $(target).bind('dblclick', function () {
                var itemIndex = store.state.checkedItems[0];
                if ($(target).attr('type') !== 'txt') {
                    return;
                }
                $(target).find('.content > div').attr('contenteditable', true);
                $(target).css('cursor', 'auto');
                $(target).find('.content>div').popline({ position: 'fixed' });
                var obj = $(target).find('.content>div')[0];
                window.getSelection().selectAllChildren(obj);
                $(target).find('.content>div').bind('blur', function () {
                    var html = $(target).find('.content>div').html();
                    // 修改数据|还原状态
                    actions.changeText(store, html, itemIndex);
                    $(target).find('.content>div').popline("destroy");
                    $(target).css('cursor', 'pointer');
                    $(target).find('.content>div').attr('contenteditable', false);
                    $(target).find('.content>div').unbind('blur')
                });
            })
        })
    }
    

    if (typeof exports == 'object') {
        module.exports = editTextItem
    } else if (typeof define == 'function' && define.amd) {
        define([], () => editTextItem)
    } else if (window.Vue) {
        window.editTextItem = editTextItem;
        Vue.use(editTextItem)
    }

}());
